$webwork.htmlEncode($page.space.name) : 5 Optimizing WMS output
This page last changed on Sep 25, 2007 by [email protected].
Objective: learn the various output format options affecting quality, speed and response size and choose the most appropriate one according to the specific application needs. Step 1: Setting up the OpenLayers PreviewIn this section you are going to setup a simplified OpenLayers client used to play with different format options for a GeoServer WMS GetMap request.
Step 2: Formats with a Vector LayerIn this section you will learn how requesting different formats impact the quality and size of an image returned from a WMS GetMap request.
Using the default options, GeoServer will return an full color image in which each pixel is a 24 bit RGB value.
Using these format options specifies to GeoServer that it should render with paletted images. A paletted image includes a color palette directly inside the image and pixels values are indexes into the palette. In this case an optimal 256 color palette is computed on the fly and each resulting pixel is 8 bits as opposed to 24 bits.
In this case instead of the palette being generated on the fly, a pre-computed palette is used. In this case an internet safe palette.
This case illustrates a rendered image without antialiasing. Furthermore, since the SLD uses just one solid color, the output will be compressed to a 1bit per pixel png. Can you see the reduction in image quality?
This case illustrates the use of a entirely different image format, in this case JPEG. Can you see the compression artifacts in the image? Step 3: Formats with a Raster LayerIn this section you will repeat the steps from the last, but with a different dataset, a raster dataset.
For reference, here is what you should see at each step:
Extra CreditBenchmarkingSo far you've seen how to check for image size, but what is the speed impact of each option? To discover this, you need to run a little benchmark, that is, a set of timed requests. Check what's the location of the ab executable, it should be in c:\ms4w\Apache\bin\ab.exe or in a similar location. Then open a command line prompt and type the following (only the start, the request url you can simple paste): c:\ms4w\Apache\bin\ab -n 30 "http://localhost:8080/geoserver/wms?HEIGHT=539&WIDTH=800&LAYERS=sf%3Astreams&STYLES=& Make sure the url is in double quotes. This will run 30 times the specified request and provide a summary of the results, included the average response time. Usually the first run includes a request that did hit the disk and it's slower, you can just run again the benchmark to avoid its effect.
Now, png8 looks bad here, but try to add the time needed to travel to the client on a decent connection, say 200kbyte/s and you may want to reconsider your opinion (hint, 10kb take 50ms to travel over the net at that speed)) For extra bonus points, do the same using the sf:dem layer, and you'll discover jpeg is not only smaller, but also faster to generate. Meta-tilingTiled rendering presents its own fair share of issues. A peculiar one has to deal with map labeling in presence of a labeling engine that does overlap avoidance and other interesting features like feature grouping (which GeoServer both have). Meta tiling is a technique that tries to lessen the adverse tiling effects by drawing group of contiguous tiles as a seamless tile (the meta tile) and crop them afterwards in smaller elements. To carry out this part of the tutorial we'll need the topp:states sample layer. First of all we need to prepare the OpenLayers code:
Now, open it again and click on the "tiled" link, in order to enable tiled rendering. Look at labels, and zoom in four times. Do you see the repeated labels? Yet, they only appear in some parts of the map, and not in others. Why? Because the preview is already using meta-tiling, and rendering is really done using 3x3 tiles (each tile being 256x256 pixels). To have a look at how label look without meta-tiling. Open states.htm and locate the lines that do set up the tiled layer. You should see a couple of options like: tiled: 'true', tilesOrigin : "-127.61950064999999,23.7351786" These are the options that do enable meta tiling, the first requires meta tiling to be enabled, the second provides the origin of the tiling system, that is, the lower
streams.htm (text/html)
streams.htm (text/html) ny-png8.png (image/png) rast-safe.png (image/png) rast-png8.png (image/png) poly-full.png (image/png) rast-jpeg.jpeg (image/jpeg) rast-jpeg.jpeg (image/jpeg) rast-full.png (image/png) dem.htm (text/html) dem.htm (text/html) streams-safe.png (image/png) streams-png8.png (image/png) streams-na.png (image/png) streams-jpeg.jpg (image/jpeg) streams-full.png (image/png) |
Document generated by Confluence on Jan 16, 2008 23:27 |